package com.dream.testtubebaby.data.product;

import java.io.Serializable;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ConfmtCenterListItemData implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id;
	private String code;
	private String name;
	private String addr;
	private String telephone;
	private String requirement;
	private String introduce;
	private String pics[];
	private double price;
	private double point;
	private int commentcount;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getRequirement() {
		return requirement;
	}

	public void setRequirement(String requirement) {
		this.requirement = requirement;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public String[] getPics() {
		return pics;
	}

	public void setPics(String[] pics) {
		this.pics = pics;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public double getPoint() {
		return point;
	}

	public void setPoint(double point) {
		this.point = point;
	}

	public int getCommentcount() {
		return commentcount;
	}

	public void setCommentcount(int commentcount) {
		this.commentcount = commentcount;
	}

	@Override
	public String toString() {
		return "ConfmtCenterListitemData [id=" + id + ", code=" + code
				+ ", name=" + name + ", addr=" + addr + ", telephone="
				+ telephone + ", requirement=" + requirement + ", introduce="
				+ introduce + "]";
	}

	public static ConfmtCenterListItemData getProductListItemDataNode(
			JSONObject jsonObject) {
		ConfmtCenterListItemData centerListitemData = new ConfmtCenterListItemData();
		long id = 0;
		try {
			id = jsonObject.getLong("id");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String code = null;
		try {
			code = jsonObject.getString("code");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String name = null;
		try {
			name = jsonObject.getString("name");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String addr = null;
		try {
			addr = jsonObject.getString("addr");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String telephone = null;
		try {
			telephone = jsonObject.getString("telephone");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String requirement = null;
		try {
			requirement = jsonObject.getString("requirement");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String introduce = null;
		try {
			introduce = jsonObject.getString("introduce");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		String []pics = null;
		try {
			JSONArray jsonBBS = new JSONArray(jsonObject.getString("pics"));
			pics = new String[jsonBBS.length()];
			for (int i = 0; i < jsonBBS.length(); i++) {
				String str = (String)jsonBBS.get(i);
				pics[i] = str;
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		double price = 0;
		try {
			price = jsonObject.getDouble("price");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		double point = 0;
		try {
			point = jsonObject.getDouble("point");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		int commentcount = 0;
		try {
			commentcount = jsonObject.getInt("commentcount");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		centerListitemData.setId(id);
		centerListitemData.setCode(code);
		centerListitemData.setName(name);
		centerListitemData.setAddr(addr);
		centerListitemData.setTelephone(telephone);
		centerListitemData.setRequirement(requirement);
		centerListitemData.setIntroduce(introduce);
		centerListitemData.setPics(pics);
		centerListitemData.setPrice(price);
		centerListitemData.setPoint(point);
		centerListitemData.setCommentcount(commentcount);
		return centerListitemData;
	}
}
